import moment from 'moment'
/**
 * 文件下载，提供文件名和文件URL即可
 * @param {string} fileName
 * @param {string} link 
 */
export const fileDownLoad = (fileName: string, link: string) => {
  const a = document.createElement('a')
  a.href = link
  a.download = fileName
  a.click()
  document.removeChild(a)
}

/**
 * 设置列表，把target的放到scoreData中
 * @param {Array} scoreData
 * @param {Array} target 
 */
export const setList = (scoreData: Array<any>, target: Array<any>) => {
  const dataList = target || []
  scoreData.splice(0, scoreData.length, ...dataList)
}

/**
 * 格式化日期
 * @param {Date|String} date
 * @param {string} format 
 */
export const formatDate = (date: any, format?: string) => moment(date).format(format || 'YYYY-MM-DD')

